package com.mercycrazy.recruit.converter;

import com.mercycrazy.recruit.enums.Role;

import javax.persistence.AttributeConverter;

/**
 * 角色枚举属性转换器
 *
 * @author <a href="mailto:1443424326@qq.com">mercycrazy</a>
 * @see Role
 * @since 2023-01-14
 */
public class RoleConverter implements AttributeConverter<Role, Integer> {

    @Override
    public Integer convertToDatabaseColumn(Role role) {
        return role.getType();
    }

    @Override
    public Role convertToEntityAttribute(Integer type) {
        return Role.of(type);
    }
}
